<template>
  <h2>promise测试</h2>
</template>

<script>
  var p = Promise.all([
    new Promise((resolve, reject) => {
      setTimeout(() => {
        resolve("aaa")
      },3000)
    }),
    new Promise((resolve, reject) => {
      setTimeout(() => {
        resolve("aaa")
      },1000)
    }),
  ])
   p.then(results => {
      console.log(" Promise.all结果")
      console.log(results)
   })

  export default {
    name: 'Promise',
    mounted: function () {
      console.log("开始promise测试")
      const p = new Promise((resolve, reject) =>{
        resolve("aaa")
      }).then(res =>{
        console.log(res,"第一层的处理结果")
        return new Promise((resolve, reject) =>{
          resolve(res + '111')
        })
      }).then( res =>{
        console.log(res,"第二层的处理结果")
        return new Promise((resolve, reject) =>{
          resolve(res + '222')
        })
      })
      p.then(function (data) {
        console.log("promise测试结果:"+data)
      })
    }
  }
</script>

<style scoped>

</style>
